<?php
 Session_Start () ;
 If (!$_SESSION ["repertoire_config"]) { Header ("Location: ../../sortie.php?sortie=3") ; }
 Include ($_SESSION ["repertoire_config"]."/garennes.cfg") ;
 Include ($_SESSION ["repertoire_config"]."/init.php") ;
 Include ("../include/config.inc") ;
 verif_droits ($droit_courant, $_SESSION ["code"]) ;
 
 $requete = var_courante ("requete", 0, null) ;
 
 If (IsSet ($requete))
  {
   Switch ($requete)
    {
     // Insertion d'un type d'appreciation
     Case 0 : $nom = var_courante ("nom", 0, "") ;
              $ok = SQL_commande ("INSERT INTO types_appreciations (nom) VALUES ('".Str_Replace ("'", "`", $nom)."')", $id_sql) ;
	      $requete = 0 ;
              Break ;
     // Effacement d'un type d'appreciation
     Case 1 : $id_type_appreciation = var_courante ("id_type_appreciation", 0, 0) ;
              $ok = SQL_commande ("DELETE FROM types_appreciations WHERE id_type_appreciation='".$id_type_appreciation."'", $id_sql) ;
	      $requete = 0 ;
	      Break ;
     // Debut de modification
     Case 2 : $id_type_appreciation = var_courante ("id_type_appreciation", 0, 0) ;
              $resultat = SQL_commande ("SELECT * FROM types_appreciations WHERE id_type_appreciation='".$id_type_appreciation."'", $id_sql) ;
              $modif = SQL_tableau_associatif ($resultat, "") ;
	      $requete = 3 ;
              Break ;
     // Fin de modification
     Case 3 : $nom = var_courante ("nom", 0, "") ;
              $id_type_appreciation = var_courante ("id_type_appreciation", 0, 0) ;
              $ok = SQL_commande ("UPDATE types_appreciations SET nom='".Str_Replace ("'", "`", $nom)."' WHERE id_type_appreciation='".$id_type_appreciation."'", $id_sql) ;
	      $requete = 0 ;
              Break ;
    }
  }
 Else
  { $requete = 0 ; }
 If (!IsSet ($modif))
  {
   $modif ["id_type_appreciation"] = 0 ;
   $modif ["nom"] = "" ;
  }
 
 $resultats = SQL_commande ("SELECT * FROM menus WHERE numero='$droit_courant' AND ordre='0'", $id_sql) ;
 $l = SQL_tableau_associatif ($resultats, "") ; 
 Echo "<HTML><HEAD>" ;
 entete_html ("Garennes", "travail", 1) ;
 Echo styles ("none", "none", "none", $l ["lien"], "none") ;
 Include ("./gestion_periodes.js") ;
 Echo " </HEAD>" ;
 
 Echo "<BODY BACKGROUND=\"../images/fond.png\" TEXT=\"#000000\" OnContextMenu=\"return false\">" ;
 Echo "<TABLE WIDTH=\"100%\" BORDER=\"0\" CELLSPACING=\"0\" CELLPADDING=\"0\">" ;
 Echo "<TR><TD WIDTH=\"100%\" ALIGN=\"CENTER\">Gestion&nbsp;des&nbsp;types&nbsp;d'appr&eacute;ciations</TD></TR>" ;
 Echo "</TABLE>" ;
 Echo "<TABLE ALIGN=\"CENTER\" BORDER=\"0\" CELLSPACING=\"1\" CELLPADDING=\"0\">" ;
 Echo "<TR><TD vALIGN=\"TOP\">" ;
 Echo "<TABLE ALIGN=\"CENTER\" BORDER=\"1\" CELLSPACING=\"0\" CELLPADDING=\"0\" style=\"border-collapse:collapse;border:1px #000000 solid\">" ;
 Echo "<FORM METHOD=\"POST\" ACTION=\"./gestion_types_appreciations.php\">" ;
 Echo "<TR><TD COLSPAN=\"4\">" ;
 Echo "<TABLE ALIGN=\"CENTER\" BORDER=\"0\" BGCOLOR=\"".$l ["lien"]."\" WIDTH=\"100%\">" ;
 If ($requete == 0)
  {
   Echo "<TR><TD ALIGN=\"CENTER\" COLSPAN=\"5\"><FONT SIZE=\"".$l ["titre"]."\">&nbsp;<B>Ajouter</B>&nbsp;</FONT></TD></TR>" ;
  }
 Else
  {
   Echo "<TR><TD ALIGN=\"CENTER\" COLSPAN=\"5\"><FONT SIZE=\"".$l ["titre"]."\">&nbsp;<B>Modifier</B>&nbsp;</FONT></TD></TR>" ;
  }
 Echo "<TR BGCOLOR=\"".$l ["nom"]."\">" ;
 Echo "<TD ALIGN=\"CENTER\"><FONT SIZE=\"".$l ["titre"]."\">&nbsp;Nom&nbsp;</TD>" ;
 Echo "<TD BGCOLOR=\"".$l ["lien"]."\"></TD>" ;
 Echo "</TR>" ;
 Echo "<TR>" ;
 Echo "<TD ALIGN=\"CENTER\"><FONT SIZE=\"".$l ["titre"]."\">&nbsp;<INPUT TYPE=\"TEXT\" NAME=\"nom\" VALUE=\"".filtrage_utf8 ($modif ["nom"])."\" SIZE=\"15\" MAXLENGTH=\"30\">&nbsp;</FONT></TD>" ;
 Echo "<TD ALIGN=\"CENTER\">" ;
 Echo "<INPUT TYPE=\"HIDDEN\" NAME=\"code\" VALUE=\"".$_SESSION ["code"]."\">" ;
 Echo "<INPUT TYPE=\"HIDDEN\" NAME=\"id_type_appreciation\" VALUE=\"".$modif ["id_type_appreciation"]."\">" ;
 Echo "<INPUT TYPE=\"HIDDEN\" NAME=\"requete\" VALUE=\"".$requete."\">" ;
 Echo "<INPUT TYPE=\"IMAGE\" SRC=\"../images/ajouter.png\" ALT=\"Ajouter/Modifier type appr&eacute;ciation\" VALUE=\"Ajouter\" BORDER=0>" ;
 Echo "</TD></TR>" ;
 Echo "<TR><TD COLSPAN=\"5\"><FONT SIZE=\"".$l ["titre"]."\">&nbsp;</FONT></TD></TR>" ;
 Echo "</TABLE></TD></TR></TABLE></TD></TR>" ;
 Echo "</FORM>" ;
 
 // Types deja saisies
 $resultat = SQL_commande ("SELECT * FROM types_appreciations ORDER BY nom", $id_sql) ;
 If (SQL_nbr_lignes ($resultat))
  {
   $nbr_p = 0 ;
   Echo "<TR><TD>&nbsp;</td></tr>" ;
   Echo "<TR><TD vALIGN=\"TOP\">" ;
   Echo "<TABLE ALIGN=\"CENTER\" BORDER=\"1\" CELLSPACING=\"0\" CELLPADDING=\"0\" BGCOLOR=\"".$l ["couleur_fond"]."\" style=\"border-collapse:collapse;border:1px #000000 solid\">" ;
   Echo "<TR BGCOLOR=\"".$l ["lien"]."\">" ;
   Echo "<TD ALIGN=\"LEFT\"><FONT SIZE=\"".$l ["titre"]."\">&nbsp;<B>Nom</B>&nbsp;</FONT></TD>" ;
   Echo "<TD ALIGN=\"CENTER\"><FONT SIZE=\"".$l ["titre"]."\">&nbsp;<B>Action</B>&nbsp;</FONT></TD>" ;
   Echo "</TR>" ;
   While ($ligne = SQL_tableau_associatif ($resultat, ""))
    {
     $nbr_p++ ;
     Echo "<TR" ;
     If ($nbr_p%2 == 0) { Echo " BGCOLOR=\"".$l ["nom"]."\"" ; }
     Echo ">" ;
     Echo "<TD ALIGN=\"LEFT\"><FONT SIZE=\"".$l ["titre"]."\">&nbsp;".filtrage_utf8 ($ligne ["nom"])."&nbsp;</FONT></TD>" ;
     Echo "<TD ALIGN=\"CENTER\">" ;
     Echo "<TABLE ALIGN=\"CENTER\" BORDER=\"0\" CELLSPACING=\"0\" CELLPADDING=\"0\">" ;
     Echo "<TR>" ;
     Echo "<FORM ACTION=\"./gestion_types_appreciations.php\" METHOD=\"POST\">" ;
     Echo "<TD>" ;
     Echo "<INPUT TYPE=\"HIDDEN\" NAME=\"code\" VALUE=\"".$_SESSION ["code"]."\">" ;
     Echo "<INPUT TYPE=\"HIDDEN\" NAME=\"id_type_appreciation\" VALUE=\"".$ligne ["id_type_appreciation"]."\">" ;
     Echo "<INPUT TYPE=\"HIDDEN\" NAME=\"requete\" VALUE=\"2\">" ;
     Echo "<INPUT TYPE=\"IMAGE\" SRC=\"../images/edition.png\" ALT=\"&Eacute;diter un type\" BORDER=0>" ;
     Echo "</TD>" ;
     Echo "</FORM>" ;
     Echo "<FORM ACTION=\"./gestion_types_appreciations.php\" METHOD=\"POST\" onSubmit=\"return valide('".Str_Replace ("'", " ", $ligne ["nom"])."')\">" ;
     Echo "<TD>" ;
     Echo "<INPUT TYPE=\"HIDDEN\" NAME=\"code\" VALUE=\"".$_SESSION ["code"]."\">" ;
     Echo "<INPUT TYPE=\"HIDDEN\" NAME=\"id_type_appreciation\" VALUE=\"".$ligne ["id_type_appreciation"]."\">" ;
     Echo "<INPUT TYPE=\"HIDDEN\" NAME=\"requete\" VALUE=\"1\">" ;
     Echo "<INPUT TYPE=\"IMAGE\" SRC=\"../images/effacer.png\" ALT=\"Supprimer le type\" BORDER=0>" ;
     Echo "</TD>" ;
     Echo "</FORM>" ;
     Echo "</TR></TABLE>" ;
     Echo "</TD></TR>";
    }
   Echo "</TD></TR></TABLE>" ;
  }
 Echo "</TABLE>" ;
 Echo "</FORM>" ;
 Echo "</BODY></HTML>" ;
?>